package cn.ee.dfs.wx;

import cn.ee.dfs.common.annotation.Log;
import cn.ee.dfs.common.controller.BaseController;
import cn.ee.dfs.common.entity.DfsResponse;
import cn.ee.dfs.common.exception.DfsException;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Controller
 *
 * @author TWJ
 * @date 2019-07-31 17:02:37
 */
@Slf4j
@RestController
@RequestMapping("api")
public class TestController extends BaseController {

    @GetMapping("ser/{serviceId}")
    public String test11(@PathVariable("serviceId") String serviceId) {
        log.info("-----from wx ------" + serviceId);
        return "i from server!!!" + serviceId;
    }

    @PostMapping("upload")
    public String test12(@RequestBody Map<String, Object> map) {
        log.info("-----from wx upload------");
        String a = (String) map.get("a");
        String b = (String) map.get("b");
        return "i from server!!!" + a + b;
    }

    @PostMapping("upload2")
    public String test13(@RequestBody JSONObject map) {
        log.info("-----from wx upload------");
        String a = (String) map.get("a");
        String b = (String) map.get("b");
        return "i from server!!!JSONObject->" + a + b;
    }

    @PostMapping("regist")
    public String regist(@RequestBody JSONObject map) {
        log.info("-----from wx upload------");
        String name = (String) map.get("name");
        String password = (String) map.get("password");
        return "regist success" + JSONObject.toJSONString(map);
    }

    @Log("删除服务")
    @GetMapping("onLogin")
    public DfsResponse deleteServiceInfo(String code) throws DfsException {

        System.out.println("code = " + code);
        return new DfsResponse().success();
    }


}
